home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / directory.man < prev    next >
Encoding:
Text File  |  1989-01-26  |  3.8 KB  |  133 lines

  1.  
  2.  
  3.  
  4. DIRECTORY             C Library Procedures              DIRECTORY
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      opendir, readdir, telldir, seekdir, rewinddir, closedir,
  10.      dirfd - directory operations
  11.  
  12. SSYYNNOOPPSSIISS
  13.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  14.      ##iinncclluuddee <<ssyyss//ddiirr..hh>>
  15.  
  16.      DDIIRR **ooppeennddiirr((ffiilleennaammee))
  17.      cchhaarr **ffiilleennaammee;;
  18.  
  19.      ssttrruucctt ddiirreecctt **rreeaaddddiirr((ddiirrpp))
  20.      DDIIRR **ddiirrpp;;
  21.  
  22.      lloonngg tteellllddiirr((ddiirrpp))
  23.      DDIIRR **ddiirrpp;;
  24.  
  25.      sseeeekkddiirr((ddiirrpp,, lloocc))
  26.      DDIIRR **ddiirrpp;;
  27.      lloonngg lloocc;;
  28.  
  29.      rreewwiinnddddiirr((ddiirrpp))
  30.      DDIIRR **ddiirrpp;;
  31.  
  32.      cclloosseeddiirr((ddiirrpp))
  33.      DDIIRR **ddiirrpp;;
  34.  
  35.      ddiirrffdd((ddiirrpp))
  36.      DDIIRR **ddiirrpp;;
  37.  
  38. DDEESSCCRRIIPPTTIIOONN
  39.      _O_p_e_n_d_i_r opens the directory named by _f_i_l_e_n_a_m_e and associates
  40.      a _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m with it.  _O_p_e_n_d_i_r returns a pointer to be
  41.      used to identify the _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m in subsequent opera-
  42.      tions.  The pointer NNUULLLL is returned if _f_i_l_e_n_a_m_e cannot be
  43.      accessed, or if it cannot _m_a_l_l_o_c(3) enough memory to hold
  44.      the whole thing.
  45.  
  46.      _R_e_a_d_d_i_r returns a pointer to the next directory entry.  It
  47.      returns NNUULLLL upon reaching the end of the directory or
  48.      detecting an invalid _s_e_e_k_d_i_r operation.
  49.  
  50.      _T_e_l_l_d_i_r returns the current location associated with the
  51.      named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m.
  52.  
  53.      _S_e_e_k_d_i_r sets the position of the next _r_e_a_d_d_i_r operation on
  54.      the _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m. The new position reverts to the one
  55.      associated with the _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m when the _t_e_l_l_d_i_r opera-
  56.      tion was performed.  Values returned by _t_e_l_l_d_i_r are good
  57.      only for the lifetime of the DIR pointer from which they are
  58.      derived.  If the directory is closed and then reopened, the
  59.      _t_e_l_l_d_i_r value may be invalidated due to undetected directory
  60.  
  61.  
  62.  
  63. Sprite v1.0             December 22, 1986                       1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. DIRECTORY             C Library Procedures              DIRECTORY
  71.  
  72.  
  73.  
  74.      compaction.  It is safe to use a previous _t_e_l_l_d_i_r value
  75.      immediately after a call to _o_p_e_n_d_i_r and before any calls to
  76.      _r_e_a_d_d_i_r.
  77.  
  78.      _R_e_w_i_n_d_d_i_r resets the position of the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m
  79.      to the beginning of the directory.
  80.  
  81.      _C_l_o_s_e_d_i_r closes the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m and frees the
  82.      structure associated with the DIR pointer.
  83.  
  84.      _D_i_r_f_d returns the integer file descriptor associated with
  85.      the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m, see open(2).
  86.  
  87.      Sample code which searchs a directory for entry ``name'' is:
  88.  
  89.           len = strlen(name);
  90.           dirp = opendir(".");
  91.           for (dp = readdir(dirp); dp != NULL; dp =
  92.      readdir(dirp))
  93.                if (dp->d_namlen == len && !strcmp(dp->d_name,
  94.      name)) {
  95.                     closedir(dirp);
  96.                     return FOUND;
  97.                }
  98.           closedir(dirp);
  99.           return NOT_FOUND;
  100.  
  101. SSEEEE AALLSSOO
  102.      open(2), close(2), read(2), lseek(2), dir(5)
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0             December 22, 1986                       2
  130.  
  131.  
  132.  
  133.